package com.whh.starter.properties;


import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Setter
@Getter
@ConfigurationProperties("whh.cipher")
public class CipherProperties {
    /**
     * 请求体/响应体是否启用加密
     */
    private Cipher body = new Cipher();


    /**
     * 是否使用国密， SM2/SM4  对应AES/RSA
     */
    private boolean sm = false;

    /**
     * 私钥,建议加密
     */
    private String privateKey;

    /**
     * 公钥,建议加密
     */
    private String publicKey;
    /**
     * 加密的类型，加密后的二进制数据用BASE64/HEX转码
     */
    private KeyType keyType = KeyType.HEX;


    public boolean allowRequestCipher(){
        return body.requestBody;
    }
    public boolean allowResponseCipher(){
        return body.responseBody;
    }

    public enum KeyType{BASE64,HEX}
    @Setter
    @Getter
    static class Cipher{
        boolean requestBody = false;
        boolean responseBody = false;

    }
}
